// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asEntityManager.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the EntityManager class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asEntityManager.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../core/EntityManager.h"


//! Binds the EntityManager class to AngelScript.
void bindEntityManager(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind EntityManager class.
    r = engine->RegisterObjectType("EntityManager", sizeof(EntityManager), asOBJ_REF); assert(r >= 0);

    // Set EntityManager behaviour.
    r = engine->RegisterObjectBehaviour("EntityManager", asBEHAVE_ADDREF, "void f()",
                                        asMETHOD(EntityManager, grab), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("EntityManager", asBEHAVE_RELEASE, "void f()",
                                        asMETHOD(EntityManager, drop), asCALL_THISCALL); assert(r >= 0);

    // Bind EntityManager class functions.
    r = engine->RegisterObjectMethod("EntityManager", "void init()",
                                     asMETHOD(EntityManager, init), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "void clear()",
                                     asMETHOD(EntityManager, clear), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("EntityManager", "bool addEntity(Entity @+)",
                                     asMETHOD(EntityManager, addEntity), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in)",
                                     asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+)",
                                     asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \
                                     "AssetGroup @+)", asMETHOD(EntityManager, createEntity),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \
                                     "AssetGroup @+, bool)", asMETHOD(EntityManager, createEntity),
                                     asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in)",
                                     asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*,
                                     AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+)",
                                     asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*,
                                     AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \
                                     "AssetGroup @+)", asMETHODPR(EntityManager, createEntityFromXML,
                                     (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL);
                                     assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \
                                     "AssetGroup @+, bool)", asMETHODPR(EntityManager, createEntityFromXML,
                                     (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL);
                                     assert(r >= 0);

    r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const u32)",
                                     asMETHODPR(EntityManager, getEntity, (const u32), Entity*),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const string &in)",
                                     asMETHODPR(EntityManager, getEntity, (const std::string &), Entity*),
                                     asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("EntityManager", "void removeEntities()",
                                     asMETHOD(EntityManager, removeEntities), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(Entity @+)",
                                     asMETHODPR(EntityManager, removeEntity, (Entity*), bool),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const u32)",
                                     asMETHODPR(EntityManager, removeEntity, (const u32), bool),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const string &in)",
                                     asMETHODPR(EntityManager, removeEntity, (const std::string &), bool),
                                     asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
